import React,{useEffect, useState} from "react";
export default class App extends React.Component{
    state={
        isCreated:true
    }
    render(){
        return(
           <div>
               <button onClick={()=>{
                   this.setState({isCreated:!this.state.isCreated})
               }}>click</button>
               {this.state.isCreated&&<Child/>}
           </div>
        )
    }
}

class Child extends React.Component{
    render(){

        return(<div>return</div>)
    }
    componentDidMout(){
        window.onresize=()=>{
            console.log("resize")
        }
        this.timer=setInterval(()=>{console.log("111")},1000)
    }
    componentWillUnmount(){
        console.log(    "componentWillUnmount")
        window.onresize=null
        clearInterval(this.timer)
    }
} 